﻿using System;
using System.Windows.Data;
using VNet.VisiSuite.Common.Helpers;

namespace VNet.VisiSuite.Common.Converters
{
    public class TicksConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int seconds = 0;
            if (value is double)
                seconds = (int) ((double) value);
            if (value is int)
                seconds = (int)value;

            return TimeHelper.SecondsToStringTime(seconds);
        }

        public object ConvertBack(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }
}
